import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int num = in.nextInt();
        if (num == 0)   System.out.print("none");
        String[] str = new String[num];
        for (int i = 0 ; i < num ; i++) {
            str[i] = in.next();
        }
        if (isLength(str) && isDic(str)) {
            System.out.print("both");
        } else if (isDic(str)) {
            System.out.print("lexicographically");
        } else if (isLength(str)) {
            System.out.print("lengths");
        } else {
            System.out.print("none");
        }
    }

    public static boolean isLength(String[] str) {
        for (int i = 0; i < str.length - 1; i++) {
            if (str[i].length() > str[i + 1].length()) {
                return false;
            }
        }
        return true;
    }

    public static boolean isDic(String[] str) {
        for (int i = 0; i < str.length - 1; i++) {
            if (str[i].compareTo(str[i + 1]) > 0) {
                return false;
            }
        }
        return true;
    }
}